import { ObjCreate } from "../../common/ObjCreate";
import { TitleItem } from "../../common/item/TitleItem";
import { Language } from "../../../../../extend/language/Language";
import { ObjTeamCreate } from "../../common/ObjTeamCreate";
import { MarryGuestRequestCell } from "../cellRenderer/MarryGuestRequestCell";
import { PageSelecter } from "../../common/pageSelect/PageSelecter";
import { GlobalStyle } from "../../../../common/global/GlobalStyle";
import { QuickBuyWindow } from "../../common/QuickBuyWindow";
import { ECategory } from "../../../../../Message/Public/ECategory";
import { EProp } from "../../../../../Message/Public/EProp";
import { Dispatcher } from "../../../../mvc/core/Dispatcher";
import { DataEvent } from "../../../events/DataEvent";
import { EventName } from "../../../mvc/EventName";
import { SWeddingApplicators } from "../../../../../Message/Public/SWeddingApplicators";
import { DataProvider } from "../../../../../fl/data/DataProvider";
import { GTileList } from "../../../../../com/mui/controls/GTileList";
import { GButton } from "../../../../../com/mui/controls/GButton";
type int = number;
//class MarryGuestRequestPanel
    
    export  class MarryGuestRequestPanel /* flash.display.Sprite */
    {
        constructor()
        {
            
            this._aryPlayer = new Array<any>();
            this.createChildren();
            this.addListeners();
            return;
        }

        /* internal  */createChildren(): void
        {
            ObjCreate.createBg(0, 0, 375, 285, this);
            var loc1=new Vector.<TitleItem>();
            loc1.push(new TitleItem(Language.getString(43606), 100));
            loc1.push(new TitleItem(Language.getString(43607), 70));
            loc1.push(new TitleItem(Language.getString(43608), 80));
            loc1.push(new TitleItem(Language.getString(43609), 115));
            var loc2=ObjTeamCreate.createTitles(loc1);
            ObjCreate.setObjAttri(loc2, 10, 7, -1, -1, this);
            this._requestTileList = ObjCreate.createTileList(10, 25, 365, 230, this);
            this._requestTileList.columnWidth = 365;
            this._requestTileList.rowHeight = 28;
            this._requestTileList.setStyle("cellRenderer", MarryGuestRequestCell);
            this._pageSelecter = ObjCreate.createPageSelecter(128, 262, this, PageSelecter.CompleteMode);
            this._btnRefuseAll = ObjCreate.createGButton("全部拒绝", 100, 293, 70, 26, this, "ButtonLarge");
            this._btnInviteAll = ObjCreate.createGButton("全部邀请", 200, 293, 70, 26, this, "ButtonLarge");
            var loc3=GlobalStyle.textFormat1;
            loc3.color = 65280;
            var loc4;
            (loc4 = ObjCreate.createTextField("", 11, 323, 280, 20, this)).htmlText = Language.getString(43610);
            loc4.addEventListener(flash.events.TextEvent.LINK, this.onTextEvent);
            return;
        }

        /* internal  */onTextEvent(arg1: Object /* flash.events.TextEvent */): void
        {
            QuickBuyWindow.instance.updateWindow(ECategory._ECategoryProp, EProp._EPropInvitation);
            QuickBuyWindow.instance.updateDefaultAmount(1);
            QuickBuyWindow.instance.show();
            return;
        }

        /* internal  */addListeners(): void
        {
            this._btnRefuseAll.addEventListener(flash.events.MouseEvent.CLICK, this.onRefuseClick);
            this._btnInviteAll.addEventListener(flash.events.MouseEvent.CLICK, this.onInviteClick);
            this.addEventListener(flash.events.Event.ADDED_TO_STAGE, this.onAddToStage);
            this._pageSelecter.addEventListener(flash.events.Event.CHANGE, this.onChange);
            return;
        }

        /* internal  */onAddToStage(arg1: Object /* flash.events.Event */): void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.MarryGetGuestApply));
            return;
        }

        /* internal  */onChange(arg1: Object /* flash.events.Event */): void
        {
            this.updateList();
            return;
        }

        /* internal  */onRefuseClick(arg1: Object /* flash.events.MouseEvent */): void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.MarryWholeReplyCardApplicators, false));
            return;
        }

        /* internal  */onInviteClick(arg1: Object /* flash.events.MouseEvent */): void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.MarryWholeReplyCardApplicators, true));
            return;
        }

        public updateApplicators(arg1: SWeddingApplicators): void
        {
            this._aryPlayer = arg1.applicators;
            this._pageSelecter.maxPage = Math.ceil(this._aryPlayer.length / this.PageSize);
            this.updateList();
            return;
        }

        /* internal  */updateList(): void
        {
            var loc1=new Array<any>();
            var loc2=(this._pageSelecter.currentPage - 1) * this.PageSize;
            var loc3=Math.min(this._pageSelecter.currentPage * this.PageSize, this._aryPlayer.length);
            var loc4=loc2;
            while (loc4 < loc3) 
            {
                loc1.push(this._aryPlayer[loc4]);
                ++loc4;
            }
            this._requestTileList.dataProvider = new DataProvider(loc1);
            return;
        }

        /* internal */ /* const */PageSize: int=8;

        /* internal */ /* var */_pageSelecter: PageSelecter;

        /* internal */ /* var */_requestTileList: GTileList;

        /* internal */ /* var */_btnRefuseAll: GButton;

        /* internal */ /* var */_btnInviteAll: GButton;

        /* internal */ /* var */_aryPlayer: Array<any>;
    }
